import request from '../request.js';

const baseUrl = 'http://106.52.75.114';

function getHotData() {
    return request({
        url: baseUrl + '/api/v2/hot/keywords'
    })
        .then(data => {
            return data;
        })
        .catch(err => {
            console.error(err.message);
            throw err;
        });
}

function getSecKillData() {
    return request({
        url: baseUrl + '/api/seckill/index?page=1&limit=8'
    })
        .then(data => {
            return data;
        })
        .catch(err => {
            console.error(err.message);
            throw err;
        });
}

function getPromotionData() {
    return request({
        url: baseUrl + '/api/home/products?page=1&limit=6&type=5&newsOrder&salesOrder&selectId&selectType=0'
    })
        .then(data => {
            return data;
        })
        .catch(err => {
            console.error(err.message);
            throw err;
        });
}

function getRankData() {
    return request({
        url: baseUrl + '/api/home/products?page=1&limit=3&type=7&newsOrder&salesOrder&selectId&selectType=0'
    })
        .then(data => {
            return data;
        })
        .catch(err => {
            console.error(err.message);
            throw err;
        });
}

export { getHotData, getSecKillData, getPromotionData, getRankData };